package com.waterdrop.wlsggk.service.impl;

import com.waterdrop.wlsggk.mapper.MaterialBuyMapper;
import com.waterdrop.wlsggk.pojo.MaterialBuy;
import com.waterdrop.wlsggk.service.IMaterialInventoryService;
import com.waterdrop.wlsggk.service.MaterialBuyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MaterialBuyServiceImpl implements MaterialBuyService {
    @Autowired
    private MaterialBuyMapper materialBuyMapper;

    @Autowired
    private IMaterialInventoryService materialInventoryService;

    @Override
    public List<MaterialBuy> selectMaterialBuyList(MaterialBuy materialBuy) {

        return materialBuyMapper.selectMaterialBuyList(materialBuy);
    }


    /**
     * 删除物料信息
     *
     * @param ids 物料ID
     * @return 结果
     */
    @Override
    public int deleteWlsggkMaterialBuy(Long[] ids) {
        return materialBuyMapper.deleteWlsggkMaterialBuyByIds(ids);
    }


    /**
     * 根据物料id查询信息
     *
     * @param id 物料ID
     * @return 结果
     */
    @Override
    public MaterialBuy selectWlsggkMaterialBuyById(Long id) {

        return materialBuyMapper.selectwlsggkMaterialBuyById(id);
    }

    /**
     * 添加物料
     *
     * @param materialBuy 物料信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insertWlsggkMaterialBuy(List<MaterialBuy> materialBuy) {
//        materialInventoryService.insertMaterialBuy(materialBuy);

        return materialBuyMapper.insertWlsggkMaterialBuy(materialBuy);

    }

    /**
     * 修改物料
     *
     * @param materialBuy 物料信息
     * @return 结果
     */

    @Override
    public int updateWlsggkMaterialBuy(MaterialBuy materialBuy) {

        return materialBuyMapper.updateWlsggkMaterialBuy(materialBuy);
    }
}
